home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / prnt / ldl.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-10-28  |  11KB  |  281 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import struct
  5. import sys
  6. PACKET_FRAME = ord('$')
  7. PACKET_PAD = 255
  8. CMD_HEADER_FMT = '>BHBBBHH'
  9. PACKET_TYPE_COMMAND = 0
  10. PACKET_TYPE_DISABLE_PACING = 1
  11. PACKET_TYPE_ENABLE_PACING = 2
  12. PACKET_TYPE_RESUME_NORMAL_OPERATION = 3
  13. PACKET_TYPE_DISABLE_RESPONSES = 4
  14. PACKET_TYPE_ENABLE_RESPONSES = 5
  15. PACKET_TYPE_RESET_LIDIL = 6
  16. PACKET_TYPE_SYNC = 7
  17. PACKET_TYPE_SYNC_COMPLETE = 8
  18. COMMAND_HANDLE_PEN = 8
  19. COMMAND_HANDLE_PEN_ENTER_PEN_CHANGE = 0
  20. COMMAND_HANDLE_PEN_COMPLETE_PEN_CHANGE = 1
  21. COMMAND_HANDLE_PEN_CLEAN_LEVEL1 = 2
  22. COMMAND_HANDLE_PEN_CLEAN_LEVEL2 = 3
  23. COMMAND_HANDLE_PEN_CLEAN_LEVEL3 = 4
  24. COMMAND_ZCA = 12
  25. COMMAND_ZCA_OPERATION = 11
  26. COMMAND_SET_PRINTER_ALIGNMENT = 12
  27. COMMAND_SET_PRINTER_ALIGNMENT_OPERATION = 6
  28. COMMAND_SET_PEN_ALIGNMENT = 12
  29. COMMAND_SET_PEN_ALIGNMENT_OPERATION = 18
  30. COMMAND_SET_PEN_ALIGNMENT_PEN_BLACK = 0
  31. COMMAND_SET_PEN_ALIGNMENT_PEN_COLOR = 1
  32. COMMAND_SET_PEN_ALIGNMENT_PEN_PHOTO = 2
  33. COMMAND_SET_PEN_ALIGNMENT_ITEM_HORT = 0
  34. COMMAND_SET_PEN_ALIGNMENT_ITEM_VERT = 1
  35. COMMAND_SET_PEN_ALIGNMENT_ITEM_BIDI = 2
  36. COMMAND_SET_PENS_ALIGNED = 12
  37. COMMAND_SET_PENS_ALIGNED_OPERATION = 14
  38. COMMAND_SET_PENS_ALIGNED_K = 1
  39. COMMAND_SET_PENS_ALIGNED_C = 2
  40. COMMAND_SET_PENS_ALIGNED_M = 4
  41. COMMAND_SET_PENS_ALIGNED_Y = 8
  42. COMMAND_SET_PENS_ALIGNED_c = 16
  43. COMMAND_SET_PENS_ALIGNED_m = 32
  44. COMMAND_SET_PENS_ALIGNED_k = 64
  45. COMMAND_SET_HUE_COMPENSATION = 12
  46. COMMAND_SET_HUE_COMPENSATION_OPERATION = 16
  47. COMMAND_SET_HUE_COMPENSATION_PEN_COLOR = 0
  48. COMMAND_SET_HUE_COMPENSATION_PEN_PHOTO = 1
  49. COMMAND_PRINT_INTERNAL_PAGE = 12
  50. COMMAND_PRINT_INTERNAL_PAGE_OPERATION = 17
  51. COMMAND_REPORT_PAGE = 12
  52. COMMAND_REPORT_PAGE_OPERATION = 21
  53. COMMAND_REPORT_PAGE_PEN_CALIBRATION = 81
  54. COMMAND_REPORT_PAGE_PEN_CALIBRATION_VERIFY = 82
  55. COMMAND_SET_PEN_ALIGNMENT_3 = 12
  56. COMMAND_SET_PEN_ALIGNMENT_3_OPERATION = 23
  57. COMMAND_SET_PEN_ALIGNMENT_3_K = 1
  58. COMMAND_SET_PEN_ALIGNMENT_3_C = 2
  59. COMMAND_SET_PEN_ALIGNMENT_3_M = 4
  60. COMMAND_SET_PEN_ALIGNMENT_3_Y = 8
  61. COMMAND_SET_PEN_ALIGNMENT_3_COLOR = 14
  62. COMMAND_SET_PEN_ALIGNMENT_3_c = 16
  63. COMMAND_SET_PEN_ALIGNMENT_3_m = 32
  64. COMMAND_SET_PEN_ALIGNMENT_3_k = 64
  65. COMMAND_SET_PEN_ALIGNMENT_3_PHOTO = 112
  66. COMMAND_QUERY = 5
  67. QUERY_PRINTER_ALIGNMENT = 3
  68. QUERY_PEN_ALIGNMENT = 15
  69. COMMAND_DYNAMIC_COUNTERS = 12
  70. COMMAND_DYNAMIC_COUNTERS_OPERATION = 5
  71.  
  72. def buildLIDILPacket(packet_type, command = 0, operation = 0, other = { }):
  73.     p = ''
  74.     if packet_type == PACKET_TYPE_DISABLE_PACING:
  75.         p = '$\x00\x10\x00\x01\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  76.     elif packet_type == PACKET_TYPE_ENABLE_PACING:
  77.         p = '$\x00\x10\x00\x02\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  78.     elif packet_type == PACKET_TYPE_RESUME_NORMAL_OPERATION:
  79.         p = '$\x00\x10\x00\x03\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  80.     elif packet_type == PACKET_TYPE_ENABLE_RESPONSES:
  81.         p = '$\x00\x10\x00\x05\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  82.     elif packet_type == PACKET_TYPE_DISABLE_RESPONSES:
  83.         p = '$\x00\x10\x00\x04\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  84.     elif packet_type == PACKET_TYPE_SYNC:
  85.         fmt = ''.join([
  86.             CMD_HEADER_FMT,
  87.             'B' * 245,
  88.             'B',
  89.             'B' * 2048])
  90.         p = struct.pack(fmt, PACKET_FRAME, 256, 0, PACKET_TYPE_SYNC, 0, 0, 2048, (0,) * 245, PACKET_FRAME, (0,) * 2048)
  91.     elif packet_type == PACKET_TYPE_SYNC_COMPLETE:
  92.         p = '$\x00\x10\x00\x08\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  93.     elif packet_type == PACKET_TYPE_RESET_LIDIL:
  94.         p = '$\x00\x10\x00\x06\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$'
  95.     elif packet_type == PACKET_TYPE_COMMAND:
  96.         if command == COMMAND_HANDLE_PEN:
  97.             fmt = CMD_HEADER_FMT + 'BBBBBB'
  98.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, PACKET_PAD, PACKET_PAD, PACKET_PAD, PACKET_PAD, PACKET_FRAME)
  99.         elif command == COMMAND_SET_PRINTER_ALIGNMENT and operation == COMMAND_SET_PRINTER_ALIGNMENT_OPERATION:
  100.             fmt = CMD_HEADER_FMT + 'BHBBBBBBBBBBBBB'
  101.             b = (0, 0, other['k_bidi'], other['c_vert'], other['c_hort'], other['c_bidi'], other['c_vert'], other['c_hort'], other['c_bidi'], other['c_vert'], other['c_hort'], other['c_bidi'], PACKET_FRAME)
  102.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, 15, *b)
  103.         elif command == COMMAND_SET_PEN_ALIGNMENT and operation == COMMAND_SET_PEN_ALIGNMENT_OPERATION:
  104.             fmt = CMD_HEADER_FMT + 'BBBbBB'
  105.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['pen'], other['item'], other['value'], PACKET_PAD, PACKET_FRAME)
  106.         elif command == COMMAND_REPORT_PAGE and operation == COMMAND_REPORT_PAGE_OPERATION:
  107.             fmt = CMD_HEADER_FMT + 'BHBBB'
  108.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['report'], PACKET_PAD, PACKET_PAD, PACKET_FRAME)
  109.         elif command == COMMAND_ZCA and operation == COMMAND_ZCA_OPERATION:
  110.             fmt = CMD_HEADER_FMT + 'BBhBB'
  111.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, 0, other['zca'], PACKET_PAD, PACKET_FRAME)
  112.         elif command == COMMAND_SET_PENS_ALIGNED and operation == COMMAND_SET_PENS_ALIGNED_OPERATION:
  113.             fmt = CMD_HEADER_FMT + 'BHBBB'
  114.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['colors'], PACKET_PAD, PACKET_PAD, PACKET_FRAME)
  115.         elif command == COMMAND_SET_HUE_COMPENSATION and operation == COMMAND_SET_HUE_COMPENSATION_OPERATION:
  116.             fmt = CMD_HEADER_FMT + 'BBbBBB'
  117.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['which'], other['value'], PACKET_PAD, PACKET_PAD, PACKET_FRAME)
  118.         elif command == COMMAND_QUERY:
  119.             fmt = CMD_HEADER_FMT + 'BBHBB'
  120.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, COMMAND_QUERY, 0, 0, 0, operation, 0, PACKET_PAD, PACKET_FRAME)
  121.         elif command == COMMAND_PRINT_INTERNAL_PAGE and operation == COMMAND_PRINT_INTERNAL_PAGE_OPERATION:
  122.             fmt = CMD_HEADER_FMT + 'BBBBBB'
  123.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, PACKET_PAD, PACKET_PAD, PACKET_PAD, PACKET_PAD, PACKET_FRAME)
  124.         elif command == COMMAND_SET_PEN_ALIGNMENT_3 and operation == COMMAND_SET_PEN_ALIGNMENT_3_OPERATION:
  125.             selections = other['selections']
  126.             num_selections = len(selections)
  127.             selections.append(PACKET_FRAME)
  128.             fmt = CMD_HEADER_FMT + 'BIB' + 'B' * (num_selections + 1)
  129.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['active_colors'], num_selections, *selections)
  130.         elif command == COMMAND_DYNAMIC_COUNTERS and operation == COMMAND_DYNAMIC_COUNTERS_OPERATION:
  131.             fmt = CMD_HEADER_FMT + 'BIB'
  132.             p = struct.pack(fmt, PACKET_FRAME, struct.calcsize(fmt), 0, PACKET_TYPE_COMMAND, command, 0, 0, operation, other['counter'], PACKET_FRAME)
  133.         
  134.     
  135.     if not len(p) >= 16:
  136.         raise AssertionError
  137.     return p
  138.  
  139.  
  140. def buildSyncPacket():
  141.     return buildLIDILPacket(PACKET_TYPE_SYNC)
  142.  
  143.  
  144. def buildSyncCompletePacket():
  145.     return buildLIDILPacket(PACKET_TYPE_SYNC_COMPLETE)
  146.  
  147.  
  148. def buildResetPacket():
  149.     return buildLIDILPacket(PACKET_TYPE_RESET_LIDIL)
  150.  
  151.  
  152. def buildGetAlignmentValues038Packet():
  153.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_QUERY, QUERY_PRINTER_ALIGNMENT)
  154.  
  155.  
  156. def buildGetAlignmentValues043Packet():
  157.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_QUERY, QUERY_PEN_ALIGNMENT)
  158.  
  159.  
  160. def buildEnableResponsesPacket(enable = True):
  161.     if enable:
  162.         return buildLIDILPacket(PACKET_TYPE_ENABLE_RESPONSES)
  163.     return buildLIDILPacket(PACKET_TYPE_DISABLE_RESPONSES)
  164.  
  165.  
  166. def buildSetPrinterAlignmentPacket(k_bidi, c_vert, c_hort, c_bidi):
  167.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PRINTER_ALIGNMENT, COMMAND_SET_PRINTER_ALIGNMENT_OPERATION, other = {
  168.         'c_vert': c_vert,
  169.         'c_hort': c_hort,
  170.         'c_bidi': c_bidi,
  171.         'k_bidi': k_bidi })
  172.  
  173.  
  174. def buildPrintInternalPagePacket():
  175.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_PRINT_INTERNAL_PAGE, COMMAND_PRINT_INTERNAL_PAGE_OPERATION)
  176.  
  177.  
  178. def buildZCAPacket(value):
  179.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_ZCA, COMMAND_ZCA_OPERATION, other = {
  180.         'zca': value })
  181.  
  182.  
  183. def buildBlackBidiPacket(value):
  184.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  185.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_BLACK,
  186.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_BIDI,
  187.         'value': value })
  188.  
  189.  
  190. def buildPhotoBidiPacket(value):
  191.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  192.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_PHOTO,
  193.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_BIDI,
  194.         'value': value })
  195.  
  196.  
  197. def buildColorBidiPacket(value):
  198.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  199.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_COLOR,
  200.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_BIDI,
  201.         'value': value })
  202.  
  203.  
  204. def buildColorHortPacket(value):
  205.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  206.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_COLOR,
  207.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_HORT,
  208.         'value': value })
  209.  
  210.  
  211. def buildColorVertPacket(value):
  212.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  213.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_COLOR,
  214.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_VERT,
  215.         'value': value })
  216.  
  217.  
  218. def buildBlackVertPacket(value):
  219.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  220.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_BLACK,
  221.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_VERT,
  222.         'value': value })
  223.  
  224.  
  225. def buildBlackHortPacket(value):
  226.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  227.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_BLACK,
  228.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_HORT,
  229.         'value': value })
  230.  
  231.  
  232. def buildPhotoHortPacket(value):
  233.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  234.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_PHOTO,
  235.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_HORT,
  236.         'value': value })
  237.  
  238.  
  239. def buildPhotoVertPacket(value):
  240.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT, COMMAND_SET_PEN_ALIGNMENT_OPERATION, other = {
  241.         'pen': COMMAND_SET_PEN_ALIGNMENT_PEN_PHOTO,
  242.         'item': COMMAND_SET_PEN_ALIGNMENT_ITEM_VERT,
  243.         'value': value })
  244.  
  245.  
  246. def buildPhotoHuePacket(value):
  247.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_HUE_COMPENSATION, COMMAND_SET_HUE_COMPENSATION_OPERATION, other = {
  248.         'which': COMMAND_SET_HUE_COMPENSATION_PEN_PHOTO,
  249.         'value': value })
  250.  
  251.  
  252. def buildColorHuePacket(value):
  253.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_HUE_COMPENSATION, COMMAND_SET_HUE_COMPENSATION_OPERATION, other = {
  254.         'which': COMMAND_SET_HUE_COMPENSATION_PEN_COLOR,
  255.         'value': value })
  256.  
  257.  
  258. def buildSetPensAlignedPacket():
  259.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PENS_ALIGNED, COMMAND_SET_PENS_ALIGNED_OPERATION, other = {
  260.         'colors': COMMAND_SET_PENS_ALIGNED_C | COMMAND_SET_PENS_ALIGNED_M | COMMAND_SET_PENS_ALIGNED_Y | COMMAND_SET_PENS_ALIGNED_c | COMMAND_SET_PENS_ALIGNED_m | COMMAND_SET_PENS_ALIGNED_k | COMMAND_SET_PENS_ALIGNED_K })
  261.  
  262.  
  263. def buildReportPagePacket(report):
  264.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_REPORT_PAGE, COMMAND_REPORT_PAGE_OPERATION, other = {
  265.         'report': report })
  266.  
  267.  
  268. def buildSetPenAlignment3Packet(active_colors, selections):
  269.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_SET_PEN_ALIGNMENT_3, COMMAND_SET_PEN_ALIGNMENT_3_OPERATION, other = {
  270.         'active_colors': active_colors,
  271.         'selections': selections })
  272.  
  273.  
  274. def buildDynamicCountersPacket(counter):
  275.     return buildLIDILPacket(PACKET_TYPE_COMMAND, COMMAND_DYNAMIC_COUNTERS, COMMAND_DYNAMIC_COUNTERS_OPERATION, other = {
  276.         'counter': counter })
  277.  
  278. if __name__ == '__main__':
  279.     pass
  280.  
  281.